fix(core): external trace context leaks across warm-started runs#3768
Conversation
🦋 Changeset detectedLatest commit: 4dc2da5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 32 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📜 Recent review details⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (28)
WalkthroughThis PR fixes a trace context leak in warm-started workers with Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed: dependency version conflict. Check your lock file or package.json. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Actionable comments posted: 0 |
On warm-started workers with
processKeepAliveenabled, every run's attempt span was exported with the first run'straceIdandparentSpanId.ExternalSpanExporterWrapperandExternalLogRecordExporterWrappercapturedexternalTraceContextatTracingSDKconstruction, and the SDK is memoized for the worker's lifetime - so the per-run reset ofStandardTraceContextManager.traceContextnever reached the wrappers.Reported by a customer running v4.4.x: 33 distinct runs on the same host/pid showed up in their APM as siblings of one parent span.
Fix: the wrappers now read external context live from the trace context manager per export. Runs without an external trace context fall through to the unchanged
externalTraceIdfallback - no behaviour change for them.Regression test in
packages/core/test/externalSpanExporterWrapper.test.tsasserts that reassigning the manager between exports produces correctly-parented spans.